#ifndef TSkinWindow_H
#define TSkinWindow_H

#include "TResizableFrame.h"
#include "TTitlebar.h"

class TSkinWindow
    : public TResizableFrame
{
    Q_OBJECT

public:
    explicit TSkinWindow(QWidget *parent = 0);
    ~TSkinWindow();

public:
    Qt::WindowState getWindowState() const
    {
        return _winState;
    }

    QRect getNormalGeometry() const;

    int hitTest(const QPoint& mpos) const;

    void changeWindowState(Qt::WindowState state);

protected slots:
    void screenWorkAreaResized(int screen);
    void moveRequested(const QPoint& globalPos, const QPoint& offset);
    void minimizeRequested();
    void normalRequested();
    void maximizeRequested();
    void closeRequested();

protected:
    void mousePressEvent(QMouseEvent* e);
    void mouseReleaseEvent(QMouseEvent* e);
    void changeEvent(QEvent* e);
    void showEvent(QShowEvent* e);
    void closeEvent(QCloseEvent* e);

    bool eventFilter(QObject* obj, QEvent* e);

protected:
    QFrame* getBackground() const
    {
        return _background;
    }

    TTitleBar* getTitlebar() const
    {
        return _titlebar;
    }

    QWidget* getClient() const
    {
        return _client;
    }

private:
    void windowStateChanged();
    void changeCursor(int ht);
    void resizeFrame();

protected:
//    QPushButton* _minimizeButton;
//    QPushButton* _maximizeButton;
//    QPushButton* _restoreButton;
//    QPushButton* _closeButton;

private:
    QFrame* _background;
    TTitleBar* _titlebar;
    QWidget* _client;
    Qt::WindowState _winState;
    Qt::WindowState _prevWinState;
    QRect _normalScreenGeometry;
    QRect _normalGeometry;
};

#endif // TSkinWindow_H
